Skip to content

Clarify find_route Documentation#4421

Open
StephenChi-hi wants to merge 1 commit intolightningdevkit:mainfrom
StephenChi-hi:main
Open

Clarify find_route Documentation#4421
StephenChi-hi wants to merge 1 commit intolightningdevkit:mainfrom
StephenChi-hi:main

Conversation

@StephenChi-hi
Copy link

@StephenChi-hi StephenChi-hi commented Feb 16, 2026

hi, in this pr i worked on improving the documentation for the find_route function inside router.rs.

i explained better how the route is built using the NetworkGraph and RouteParameters, and how fees are added up along the path. i also described how the cltv expiry is combined through the hops, and how ScoreLookUp can affect which path is chosen.

i added more detail about how first_hops is used to pick outbound channels, and also listed the possible errors the function can return.

i just wanted to make it easier for anyone reading the code to understand how route finding actually works and what to expect when calling this function.

this is part of my first open source contributions, so if anything should be adjusted or written better please let me know. i really appreciate the effort that has gone into this project already.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 16, 2026

I've assigned @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.06%. Comparing base (3497b59) to head (ed9e157).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4421      +/-   ##
==========================================
- Coverage   86.09%   86.06%   -0.03%     
==========================================
  Files         156      156              
  Lines      103623   103623              
  Branches   103623   103623              
==========================================
- Hits        89211    89187      -24     
- Misses      11895    11919      +24     
  Partials     2517     2517              
Flag Coverage Δ
tests 86.06% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/// However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` /
/// `htlc_maximum_msat` *are* checked as they may change based on the receiving node.
///
/// Routes are constructed by searching the provided [`NetworkGraph`] for paths from the payer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads as a second introductory sentence, maybe it should simply replace the first sentence instead?

///
/// Routes are constructed by searching the provided [`NetworkGraph`] for paths from the payer
/// to the payee that satisfy the constraints in [`RouteParameters`]. Fees are accumulated
/// backwards from the payee to the payer, and CLTV expiry deltas are aggregated hop-by-hop.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"accumulated backwards" doesn't really tell me what this means or why its important if I don't know LN super well. Maybe its worth just leaving out or tweaking, though I'm not quite sure how to do so, maybe something like this?

Suggested change
/// backwards from the payee to the payer, and CLTV expiry deltas are aggregated hop-by-hop.
/// by totaling fees at each hop from the payee to the payer, and CLTV expiry deltas are aggregated hop-by-hop.

/// backwards from the payee to the payer, and CLTV expiry deltas are aggregated hop-by-hop.
///
/// Channel selection and path ranking are influenced by the provided [`ScoreLookUp`]
/// implementation, which may apply penalties based on historical reliability,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention how the penalties are included.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments